/*
 *  QMWidget.h
 *  QuickMatch
 *
 *  Created by Leroy Ketelaars on 8/13/09.
 *  Copyright 2009 Universum7. All rights reserved.
 *
 */

#ifndef __QM_WIDGET_H__
#define __QM_WIDGET_H__

#include "SDL.h"

#define TOPLEFTCORNER 		0
#define TOPEDGE				0
#define TOPRIGHTCORNER		1
#define LEFTEDGE			1
#define BOTTOMLEFTCORNER	2
#define BOTTOMEDGE			2
#define BOTTOMRIGHTCORNER	3
#define RIGHTEDGE			3

class QMWidget
{
public:
	SDL_Surface*		corners[4];
	SDL_Surface*		edges[4];
	SDL_Surface*		fill;
	SDL_Rect			bounds;
	
	QMWidget()
	{
		this->blankData();
	}
	~QMWidget()
	{
		printf("QMWidget: Deleting instance @ %p\n", this);
		for(int i = 0; i < 4; i++)
		{
			if(corners[i] != NULL)
			{
				SDL_FreeSurface(corners[i]);
				corners[i] = NULL;
			}
			else 
			{ 
				printf("\tnot deleting corner %d graphics\n", i);
			}
			if(edges[i] != NULL)
			{
				SDL_FreeSurface(edges[i]);
				edges[i] = NULL;
			}
			else 
			{ 
				printf("\tnot deleting edge %d graphics\n", i);
			}
		}
		if(fill != NULL)
		{
			SDL_FreeSurface(fill);
		}
		else 
		{ 
			printf("\tnot deleting fill graphics\n");
		}
	}
	void blankData()
	{
		fill = NULL;
		for(int i = 0; i < 4; i++)
		{
			corners[i] = edges[i] = NULL;
		}
		printf("QMWidget blanked graphics pointers for widget @ %p\n", this);
	}
	void setCorners(SDL_Surface* c1,SDL_Surface* c2,SDL_Surface* c3,SDL_Surface* c4)
	{
		corners[0] = c1; corners[1] = c2; corners[2] = c3; corners[3] = c4;
	}
	void setEdges(SDL_Surface* c1,SDL_Surface* c2,SDL_Surface* c3,SDL_Surface* c4)
	{
		edges[0] = c1; edges[1] = c2; edges[2] = c3; edges[3] = c4;
	}
};


#endif
